#!/bin/bash
mkdir backup
cp *rank*.txt backup
mydirs="ex ey ez bx by bz jx jy jz rho"
for ndir in $mydirs
do
    rm -rvf $ndir
    mkdir $ndir
    mv *rank*$ndir".txt" $ndir
    cp gather.py $ndir
    cd $ndir
    python gather.py
    cd ../
    rm -rvf $ndir
done
mydirl="dens*_Ele dens*_Ion ek_Ele* ek_Ion* ek_Pho ek_Pos ek_Car ek_Cu dens*_Pho dens*_Car dens*_Pos dens*_Cu dens*_Au ek_Au dens*_Pro ek_Pro*"
for ndir in $mydirl
do
    rm -rvf $ndir
    mkdir $ndir
    mv *rank*[0-9]_$ndir*".txt" $ndir
    cp gathers.py $ndir
    cd $ndir
    python gathers.py
    cd ../
    rm -rvf $ndir
done

mydirp="_Electron _Ion _Photon _Carbon _Posi _Cu _Au _detector _Proton"
for ndir in $mydirp
do
    rm -rvf $ndir
    mkdir $ndir
    mv *rank*[0-9]$ndir*".txt" $ndir
    cp gatherp.py $ndir
    cd $ndir
    python gatherp.py
    cd ..
    rm -rvf $ndir
done



mkdir ptcls
mv *[0-9]_Ele* ptcls
mv *[0-9]_Pho* ptcls
mv *[0-9]_Ion* ptcls
mv *[0-9]_Pos* ptcls
mv *[0-9]_Cu*  ptcls
mv *[0-9]_Car* ptcls
mv *[0-9]_Au* ptcls
mv *[0-9]_dete* ptcls
